package com.ogilvy.cms.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.ogilvy.cms.bean.CmsPage;
import com.ogilvy.cms.dao.CmsPageDao;
import com.ogilvy.cms.service.CmsPageService;
import com.ogilvy.frame.service.BaseServiceImpl;

@Service
public class CmsPageServiceImpl extends BaseServiceImpl implements CmsPageService{

	@Autowired
	protected  CmsPageDao  cmsPagedao;

	public CmsPage add(CmsPage cmsPage) {
		CmsPage entity = cmsPagedao.save(cmsPage);
		return entity;
	}

	public boolean del(Integer cmpId) {
		cmsPagedao.deleteById(cmpId);
		return true;
	}

	public boolean modify(CmsPage cmsPage) {
		// TODO Auto-generated method 
		cmsPagedao.update(cmsPage);
		return true;
	}

	public List<CmsPage> query(CmsPage cmsPage) {
		System.out.println("cmspageserviceimp 获取的page名字::"+cmsPage.getCmpTitleName());
		if(isEmpty( cmsPage.getCmpTitleName())){
			System.out.println("cmspageserviceImp :: 执行了findAll");
			return cmsPagedao.findAll();
		}
		return cmsPagedao.findByProperty("cmpTitleName", cmsPage.getCmpTitleName());
	}

	//通过ID进行查询
	public CmsPage get(Integer cmpId){
		return cmsPagedao.get(cmpId);
	}

}
